package sort.nowcoder.easy;

import java.util.*;

/**
 * @author bruin_du
 * @description 马戏团
 * @date 2022/7/9 18:16
 **/
public class Circus {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Person> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int num = in.nextInt();
            list.add(new Person(in.nextInt(), in.nextInt()));
        }
        Collections.sort(list, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o2.weight - o1.weight;
            }
        });
        Collections.sort(list, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o2.height - o1.height;
            }
        });
        Collections.sort(list, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o2.height - o1.height;
            }
        });
        int count = 1;
        Person max = list.get(0);
        for (int i = 1; i < n; i++) {
            Person tmp = list.get(i);
            if (max.height >= tmp.height && max.weight >= tmp.weight) {
                count++;
            } else {
                break;
            }
            max = tmp;
        }
        System.out.println(count);

    }
}

class Person {
    int weight;
    int height;
    int sum;

    public Person(int weight, int height) {
        this.weight = weight;
        this.height = height;
    }
}
